/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PreviewPanel.java
 *
 * Created on 14.Haz.2009, 15:25:11
 */

package com.meraklisina.latexeditor;
import com.sun.pdfview.PDFFile;
import com.sun.pdfview.PDFPage;
import javax.swing.JFrame;
import java.io.IOException;
/**
 *
 * @author vedat.ekiz
 */
public class PreviewPanel extends javax.swing.JPanel {

    /** Creates new form PreviewPanel */
    public PreviewPanel() {
        initComponents();
    }

    private JFrame parentContainer;

    public PreviewPanel(JFrame parentContainer) {
        this.parentContainer = parentContainer;
    }

    public void Update(PDFFile pdfFile, int pageNumber, boolean hard) throws IOException{
        PDFPage page = pdfFile.getPage(pageNumber);
        pdfPagePanel.showPage(page);
        pdfPagePanel.waitForCurrentPage();
        pdfPagePanel.validate();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pdfPagePanel = new com.sun.pdfview.PagePanel();

        pdfPagePanel.setBackground(new java.awt.Color(204, 204, 204));
        pdfPagePanel.setName("pdfPagePanel"); // NOI18N

        javax.swing.GroupLayout pdfPagePanelLayout = new javax.swing.GroupLayout(pdfPagePanel);
        pdfPagePanel.setLayout(pdfPagePanelLayout);
        pdfPagePanelLayout.setHorizontalGroup(
            pdfPagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 323, Short.MAX_VALUE)
        );
        pdfPagePanelLayout.setVerticalGroup(
            pdfPagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 457, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pdfPagePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pdfPagePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 457, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.sun.pdfview.PagePanel pdfPagePanel;
    // End of variables declaration//GEN-END:variables

}
